package com.bishe.app.modules.groupDaySaleCount.model;

import com.alibaba.fastjson.JSON;
import com.bishe.app.modules.groupDaySaleCount.entity.GroupDaySaleCount;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Created : 2024/4/23, 20:13
 *
 * @author : jeffrey.hu
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class GroupDayCount {

    private String saleA;

    private String saleB;

    public static GroupDayCount init() {
        return new GroupDayCount("0", "0");
    }

    public static GroupDayCount fromCountEntity(GroupDaySaleCount groupDaySaleCount) {
        if (groupDaySaleCount == null) {
            return init();
        }
        if (groupDaySaleCount.getSaleItem() == null) {
            return init();
        }

        return JSON.parseObject(groupDaySaleCount.getSaleItem(),
                GroupDayCount.class);
    }
}
